﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Management;

namespace IFRS.Web
{
    public class Report
    {
        public List<ReportParameter> Parameters { get; set; }
        public string ReportName { get; set; }

        public Report()
        {
            this.Parameters = new List<ReportParameter>();
        }

        public string CreatePreview()
        {
            string ReportUrl = WebConfigurationManager.AppSettings["ReportUrl"] + this.ReportName;
            string ParameterList = "&";
            foreach (ReportParameter Param in this.Parameters)
            {
                ParameterList += Param.ParameterName + "=" + Param.ParameterValue.ToString() + "&";
            }
            ParameterList = ParameterList.TrimEnd('&');

            //ScriptManager.RegisterStartupScript(pg, pg.GetType(), (new Guid()).ToString(), "window.open('" + ReportUrl + ParameterList + "')", true);
            return ReportUrl + ParameterList;
        }
    }

    public class ReportParameter
    {
        public string ParameterName { get; set; }
        public object ParameterValue { get; set; }

        public ReportParameter(string Name, object Value)
        {
            this.ParameterName = Name;
            this.ParameterValue = Value;
        }
    }
}